
import React, { Component } from 'react'
import ComponentTest from './views/ComponentTest';
  import TextComponent from './component/TextComponent';
 class App extends Component {
  state={
    arr:true
  }
      componentDidMount(){
          console.log(this.refs.textBox);
          console.log(this.props);
          
      } 
     
      // 更新
  componentDidUpdate(){
    console.log("更新了");
    
  }
componentWillUnmount(){
  //卸载 销毁
  console.log("父组件");
  
}

/* shouldComponentUpdate(nextProps:any,nestState:any){
      console.log(nextProps,"nextProps");
      console.log(nestState,"nestState");
      
  if(nextProps.arr){
         return true //组件重新渲染
    }else{
      return false //不重新触发render
    }
} */

  render() {
  const testclick=()=>{
    console.log(this.state.arr);
    
    this.setState({
      arr:!this.state.arr
    })
  }
    return (
      <div ref="testBox">
       
        {this.state.arr?<TextComponent></TextComponent>:"无"}
        <button onClick={()=>testclick()}>更新</button>
      </div>
    )
  }
}

export default App
